import 'package:flutter/material.dart';
import '../../utils/navigator_utils.dart';
import 'app_2_1_counter.dart';
import 'app_2_2_random_word.dart';
import 'app_2_5_route.dart';

// 第二章 路由管理

class TwoRoute extends StatefulWidget {
  @override
  _TwoRouteState createState() => new _TwoRouteState();
}

class _TwoRouteState extends State<TwoRoute> {
  //列表显示的组件
  List<Widget> _wls;

  @override
  void initState() {
    super.initState();
    _wls = [
      RaisedButton(
        child: Text("计数器"),
        onPressed: () => NavigatorUtil.goPageByPush(context, new CounterRoute()),
      ),
      RaisedButton(
        child: Text("随机字符串"),
        onPressed: () => NavigatorUtil.goPageByPush(context, new RandomWordsRoute()),
      ),
      RaisedButton(
        child: Text("路由相关"),
        onPressed: () => NavigatorUtil.goPageByPush(context, new MyRoute()),
      ),
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("第二章：第一个Flutter应用"),
      ),
      body: Container(
        margin: EdgeInsets.only(left: 20.0),
        child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: _wls),
      ),
    );
  }
}
